import { defineComponent, h, ref, watch } from '@vue/runtime-core'
import bulletImg from '../../assets/bullet.png'
import enemyBulletImg from '../../assets/bunny.png'

export const myBulletInfo = {
    width: 61,
    height: 99,
    dir: -1
}
export const enemyBulletInfo = {
    width: 61,
    height: 99,
    dir: 1
}

export default defineComponent({
    props: ['x', 'y', 'dir'],
    setup (props, ctx) {
        const x = ref(props.x)
        const y = ref(props.y)

        watch(props, (newValue) => {
            //console.log(newValue)
            x.value = newValue.x
            y.value = newValue.y
        })

        return { 
            x,
            y,
            dir: props.dir
        }
    },
    render (ctx) {
        return h('Sprite',{
            x: ctx.x,
            y: ctx.y,
            texture: ctx.dir === -1 ? bulletImg : enemyBulletImg})
    }
})